
/*js截取简介的字符串 */
var introduction = document.getElementsByClassName("introduction");
console.log(introduction)

for(let  i = 0;i<introduction.length;i++){
    var oldintroductioncontain = introduction[i].innerHTML.replace(/^\s*|\s*$/g, "")
    if (introduction[i].innerHTML.replace(/^\s*|\s*$/g, "").length>40){
        var newintroductioncontain = introduction[i].innerHTML.replace(/^\s*|\s*$/g, "").substring(0, 40) + "...";
        introduction[i].innerHTML = newintroductioncontain
    }else{
        introduction[i].innerHTML = introduction[i].innerHTML
    }
}

/*根据两种类型进行遍历数据！！！！ */
function allvideo(videoTags, videoType){
    axios({
        url: '/findVideoByTypeAndTags',
        method: 'get',
        params: {
            videoTags: videoTags,
            videoType: videoType,
        }
    })
        .then(function (data) {
                containDetailed.innerHTML = ""
                for (let i = 0; i < data.data.data.data.length; i++) {
                    containDetailed.innerHTML += `
                <a href="/play?${data.data.data.data[i].videoId}">
                            <div id="div" style="margin-left: 10%;width: 80%;height: 219px;">
                <div style="width: 140px;height: 187px;float: left;">
                    <img src='${data.data.data.data[i].videoPhoto}'' style="width: 100%;height: 100%;">
                </div>
                <div style="width: 84%;height: 187px;float: left;line-height: 16px;font-size: 14px; color: rgba(24,25,30,.92);">
                    <div style="opacity: .92;font-size: 16px;color: #18191e;position: relative;top: 10px;">${data.data.data.data[i].videoName}</div>
                    <div style="height: 15%;">
                        <span style="padding: 2px; border-radius: 6px 6px 6px 1px;color: #f63;background-color: rgba(255,102,51,.1);">
                                7552弹幕
                        </span>
                        <span style="padding: 2px; border-radius: 6px 6px 6px 1px;margin-left: 20px;color: #f63;background-color: rgba(255,102,51,.1);">
                            ${data.data.data.data[i].videoYear}
                        </span>
                        <p class="videoid" style="display:none;">${data.data.data.data[i].videoId}</p>
                    </div>
                    <div>
                        <span>
                            ${data.data.data.data[i].videoType} / ${data.data.data.data[i].videoYear} /${data.data.data.data[i].videoTags} /${data.data.data.data[i].nickName}
                        </span>

                    </div>
                    <div style=" font-size: 14px; color: rgba(24,25,30,.6);width:96%;">
                            ${data.data.data.data[i].introduction}

                    </div>
                </div>
            </div>
                </a>
            
            
            `
                }

        })
        .catch(function (error) {
            console.log(error)
            console.log('遍历根据电影标签选择电影榜单失败')
        })
}

allvideo("热播榜","电影")


/*进行切换榜单 */
var toptext = document.getElementsByClassName("toptext");
for (let i = 0; i < toptext.length;i++){
    toptext[i].onclick = function(){
        // console.log(toptext[i].innerHTML)
        var first = toptext[i].innerHTML
        for (let j = 0; j < toptext.length; j++) {
            toptext[j].style.color = "black"
        }
        toptext[i].style.color = "#ff6147"

        /*点击总的类型的时候获取下面的 */
        var bottomText = document.getElementsByClassName("bottomText");
        console.log(bottomText)
        for (let k = 0; k < bottomText.length; k++) {
            if (bottomText[k].style.color == "rgb(255, 97, 71)") {
                console.log(bottomText[k].innerHTML)/*确定分类型 */
                console.log(first, bottomText[k].innerHTML)
                allvideo(bottomText[k].innerHTML,first)
            }

        }


    }

}

/*进行切换榜单 */
var bottomText = document.getElementsByClassName("bottomText");
console.log(bottomText)
for (let i = 0; i < bottomText.length; i++) {
    bottomText[i].onclick = function () {
        for (let j = 0; j < bottomText.length; j++) {
            bottomText[j].style.color = "black"
        }
        bottomText[i].style.color = "#ff6147"
        var lll = bottomText[i].innerHTML

        /*点击总的类型的时候获取下面的 */
        var toptext = document.getElementsByClassName("toptext");
        console.log(toptext)
        for (let k = 0; k < toptext.length; k++) {
            if (toptext[k].style.color == "rgb(255, 97, 71)") {
                console.log(toptext[k].innerHTML)/*确定分类型 */
                allvideo(lll, toptext[k].innerHTML)
            }
        }
    }
}



































